package Solutions

func rearrangeArray(nums []int) []int {
    var pp,np=-1,-1
    for ind:=0; pp==-1||np==-1;ind++{
        if nums[ind]>0&&pp==-1{
            pp=ind
        }else if nums[ind]<0&&np==-1{
            np=ind
        }
    }
    ans:=make([]int,len(nums))
    for i:=0;i<len(nums);i++{
        if i&1==1{
            ans[i]=nums[np]
            np++
            for np<len(nums)&&nums[np]>0{
                np++
            }
        }else{
            ans[i]=nums[pp]
            pp++
            for pp<len(nums)&&nums[pp]<0{
                pp++
            }
        }
    }
    return ans
}